import numpy as np

import tensorflow as tf

import user_vec as uv
import time


K = 6
vec = np.load("films_vec.npy", allow_pickle="TRUE")
mid = np.load("films_mid.npy", allow_pickle="TRUE")

distance = []
user_vec  = uv.get_vec(5)
start_time = time.time()

for i in range(len(vec)):
    tmp = uv.euclidean_distance_by_tf(vec[i], user_vec)
    distance.append(tmp)
tenser_dis = tf.convert_to_tensor(distance)

top6 = tf.nn.top_k(tenser_dis, k=K, sorted=True)
end_time = time.time()


films = np.load("films_list.npy", allow_pickle="TRUE")
for each in top6.indices:
    film = films[each]
    print(film)
    
print(end_time - start_time)